export default [
  {
    path: '/center',
    name: 'center',
    component: () => import('@/views/Center/index.vue'),
    meta: { showFooter: true },
    children: [
      //子路由重定向
      { path: '/center', redirect: '/center/myorder' },
      { path: 'myorder', component: () => import('@/views/Center/MyOrder/index.vue') },
      { path: 'grouporder', component: () => import('@/views/Center/GroupOrder/index.vue') },
    ],
  },
  {
    path: '/paysuccess',
    name: 'paysuccess',
    component: () => import('@/views/PaySuccess/index.vue'),
    meta: { showFooter: true },
    beforeEnter: (to, from, next) => {
      // reject the navigation
      //如果是从pay页面跳转到paysuccess则允许跳转
      if (from.path.indexOf('/pay') != -1) {
        next()
      } else {
        //禁止跳转，停留在原页面
        next(false)
      }
    },
  },
  {
    path: '/pay',
    name: 'pay',
    component: () => import('@/views/Pay/index.vue'),
    meta: { showFooter: true },
    beforeEnter: (to, from, next) => {
      if (from.path.indexOf('/trade') != -1) {
        next()
      } else {
        next(false)
      }
    },
  },
  {
    path: '/trade',
    name: 'trade',
    component: () => import('@/views/Trade/index.vue'),
    meta: { showFooter: true },
    beforeEnter: (to, from, next) => {
      if (from.path.indexOf('/shopcart') != -1) {
        next()
      } else {
        next(false)
      }
    },
  },
  {
    path: '/shopcart',
    name: 'shopcart',
    component: () => import('@/views/ShopCart/index.vue'),
    meta: { showFooter: true },
  },
  {
    path: '/addcartsuccess',
    name: 'addcartsuccess',
    component: () => import('@/views/AddCartSuccess/index.vue'),
    meta: { showFooter: true },
  },
  {
    path: '/detail/:id',
    component: () => import('@/views/Detail/index.vue'),
    meta: { showFooter: true },
  },
  {
    path: '/',
    redirect: '/home',
  },
  {
    path: '/home',
    name: 'home',
    component: () => import('@/views/Home/index.vue'),
    //Footer组件显示
    meta: { showFooter: true },
  },
  {
    path: '/search/:keyword?',
    name: 'search',
    component: () => import('@/views/Search/index.vue'),
    meta: { showFooter: true },
  },
  {
    path: '/login',
    component: () => import('@/views/Login/index.vue'),
    //Footer组件隐藏
    meta: { showFooter: false },
  },
  {
    path: '/register',
    component: () => import('@/views/Register/index.vue'),
    meta: { showFooter: false },
  },
]
